package com.quan.api.pms;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quan.commons.core.bean.R;
import com.quan.commons.core.biz.support.MyBaseController;
import com.quan.commons.core.utils.PageUtils;
import com.quan.mall.commons.vo.PmsSpuVo;
import com.quan.mall.entity.PmsSpu;
import com.quan.mall.service.PmsSpuService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 商品-SPU基本信息
 * @author yhaoquan
 * @email yhaoquan@163.com
 * @date 2021-02-09 11:44:02
 */
@Slf4j
@Api(tags = "商品-SPU基本信息")
@RestController
@RequestMapping("/api/mall/pmsspu")
public class ApiPmsSpuController extends MyBaseController {

    @Autowired
    private PmsSpuService service;


    /**
     * 多条件查询信息详情
     * @param vo
     * @return
     */
    @GetMapping("/info")
    public R info(PmsSpuVo vo) {
        QueryWrapper<PmsSpu> queryWrapper = new QueryWrapper<PmsSpu>(vo);
        PmsSpu pmsSpu = this.service.getOne(queryWrapper);
        return R.ok().put("data", pmsSpu);
    }

    @GetMapping("/getGoodsInfo")
    public R getGoodsInfo(PmsSpuVo vo) {
        PmsSpuVo pmsSpu = this.service.getGoodsInfo(vo);
        return R.ok().put("data", pmsSpu);
    }

    /**
     * 根据ID查询信息详情
     * @param {id}
     * @return
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        PmsSpu pmsSpu = this.service.getById(id);
        return R.ok().put("data", pmsSpu);
    }


    /**
     * 分页查询
     * @param vo
     * @return
     */
    @GetMapping(value = "page")
    public R queryPage(PmsSpuVo vo) {
        PageUtils page = this.service.queryPage(new PageUtils(request), vo);
        return R.ok().put("data", page);
    }

}
